<!DOCTYPE html>
<html lang="ch">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Ovio -  Bootstrap Based Responsive Dashboard &amp; Admin Template</title>

<!-- Bootstrap -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">

<!-- Google Font -->
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700" rel="stylesheet">

<!-- Template style -->
<link rel="stylesheet" href="dist/css/style.css">
<link rel="stylesheet" href="dist/et-line-font/et-line-font.css">
<link rel="stylesheet" href="dist/font-awesome/css/font-awesome.min.css">
<link type="text/css" rel="stylesheet" href="dist/weather/weather-icons.min.css">
<link type="text/css" rel="stylesheet" href="dist/weather/weather-icons-wind.min.css">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

<script src="plugins/charts/code/highcharts.js"></script>
</head>

<body class="sidebar-mini">
<div class="wrapper">

  <!-- 引入顶栏 -->
  <header class="main-header dark-bg">

    <!-- Logo -->
    <a href="index.html" class="logo dark-bg">
      <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><img src="dist/img/logo.png" alt="Ovio"></span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><img src="dist/img/logo-lg.png" alt="Ovio"></span> </a>

    <!-- Header Navbar -->
    <nav class="navbar navbar-static-top" role="navigation">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button"> <span class="sr-only">Toggle navigation</span> </a>
      <!-- Navbar Right Menu -->
      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">


          <!--邮箱登录-->
          <li class="dropdown notifications-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-envelope"></i>
            <div class="notify"> <span class="heartbit"></span> <span class="point"></span> </div>
          </a>
            <ul class="dropdown-menu">
              <li class="header" style="text-align: center"><span>请输入您的邮箱和授权码</span><br/>
                <span>--（目前仅支持QQ邮箱）--</span></li>
              <li>
                <input type="text" name="search" class="form-control" id="emailLogin" disabled="disabled" style="text-align: center;margin-top: 5%">
                <input type="text" name="search" class="form-control" id="password" placeholder="--请输入授权码--" style="text-align: center;margin-top: 5%">
              </li>
              <li class="footer" style="text-align: center;margin-top: 5%"><button type="button" class="btn btn-primary btn-outline btn-rounded" id="emailLoginButton">登录</button></li>
            </ul>
          </li>


          <!--收信箱-->
          <li class="dropdown messages-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-megaphone"></i>
            <div class="notify"> <span class="heartbit"></span> <span class="point"></span> </div>
          </a>
            <ul class="dropdown-menu">
              <li class="header">您有<span id="emailNum">X</span>条邮件未读</li>
              <li>
                <ul class="menu" id="emailList">
                  <!--<li><a href="#">-->
                  <!--<div class="pull-left"><img src="dist/img/img1.jpg" class="img-circle" alt="User Image"></div>-->
                  <!--<h4>Florence Douglas</h4>-->
                  <!--<p>Lorem ipsum dolor sit amet.</p>-->
                  <!--<p><small><i class="fa fa-clock-o"></i> 2 mins</small></p>-->
                  <!--</a></li>-->
                  <!--<li><a href="#">-->
                  <!--<div class="pull-left"><img src="dist/img/img2.jpg" class="img-circle" alt="User Image"></div>-->
                  <!--<h4>Douglas Smith</h4>-->
                  <!--<p>Lorem ipsum dolor sit amet.</p>-->
                  <!--<p><small><i class="fa fa-clock-o"></i> 15 mins</small></p>-->
                  <!--</a></li>-->
                  <!--<li><a href="#">-->
                  <!--<div class="pull-left"><img src="dist/img/img3.jpg" class="img-circle" alt="User Image"></div>-->
                  <!--<h4>Lorence Deo</h4>-->
                  <!--<p>Lorem ipsum dolor sit amet.</p>-->
                  <!--<p><small><i class="fa fa-clock-o"></i> 35 mins</small></p>-->
                  <!--</a></li>-->
                  <!--<li><a href="#">-->
                  <!--<div class="pull-left"><img src="dist/img/img1.jpg" class="img-circle" alt="User Image"></div>-->
                  <!--<h4>Florence Douglas</h4>-->
                  <!--<p>Lorem ipsum dolor sit amet.</p>-->
                  <!--<p><small><i class="fa fa-clock-o"></i> 2 mins</small></p>-->
                  <!--</a></li>-->
                </ul>
              </li>
              <li class="footer"><a href="#">--进入邮箱--</a></li>
            </ul>
          </li>

          <!--右侧头像框-->
          <li class="dropdown user user-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <img src="dist/img/img1.jpg" class="user-image" alt="User Image"> <span class="hidden-xs"><span class="adminName">Florence Douglas</span></span> </a>
            <ul class="dropdown-menu">
              <li class="user-header">
                <div class="pull-left user-img"><img src="dist/img/img1.jpg" class="img-responsive" alt="User"></div>
                <p class="text-left"> <span class="adminName">Florence Douglas</span> <small id="email">florence@gmail.com</small> </p>
                <div class="view-link text-left"><a href="#">个人信息</a> </div>
              </li>
              <li><a href="#"><i class="icon-gears"></i> 账号设置</a></li>
              <li role="separator" class="divider"></li>
              <li><a href="adminOut"><i class="fa fa-power-off"></i> <span id="adminOut">退出登录</span></a></li>
            </ul>
          </li>
        </ul>
      </div>
    </nav>
  </header>

  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar dark-bg">
    <section class="sidebar">
      <div class="user-panel black-bg">
        <div class="pull-left image"> <img src="dist/img/img1.jpg" class="img-circle" alt="User Image"> </div>
        <div class="pull-left info">
          <p class="adminName">Florence Douglas</p>
          <a href="#"><i class="fa fa-circle"></i> Online</a> </div>
      </div>
      <!-- Sidebar Menu -->
      <ul class="sidebar-menu" data-widget="tree">
        <li class="header dark-bg">Menu</li>
        <li class="treeview active"><a href="#"><i class="fa fa-dashboard"></i> <span>数据详情</span> <span class="pull-right-container"> <i class="fa fa-angle-left pull-right"></i> </span> </a>
          <ul class="treeview-menu ">
            <li><a href="index.html"><i class="fa fa-angle-right"></i> 数据详情 1</a></li>
            <li class="active"><a href="getMoreTodayFund.html"><i class="fa fa-angle-right"></i> 数据详情 2</a></li>
            <li><a href="dashboard-3.html"><i class="fa fa-angle-right"></i> 数据详情 3</a></li>
          </ul>
        </li>
        <li class="treeview"> <a href="#"><i class="fa fa-table"></i> <span>权限管理</span> <span class="pull-right-container"> <i class="fa fa-angle-left pull-right"></i> </span> </a>
          <ul class="treeview-menu">
            <li><a href="userManage.html"><i class="fa fa-angle-right"></i> 用户管理</a></li>
            <li><a href="adminManage.html"><i class="fa fa-angle-right"></i> 管理员管理</a></li>
            <li><a href="goodManage.html"><i class="fa fa-angle-right"></i> 商品管理</a></li>
          </ul>
        </li>
        <li class="treeview"> <a href="#"><i class="fa fa-bar-chart"></i> <span>业务管理</span> <span class="pull-right-container"> <i class="fa fa-angle-left pull-right"></i> </span> </a>
          <ul class="treeview-menu">
            <li><a href="charts/line.html"><i class="fa fa-angle-right"></i> 资质维护</a></li>
            <li><a href="charts/area.html"><i class="fa fa-angle-right"></i> 分类管理</a></li>
            <li><a href="charts/bar.html"><i class="fa fa-angle-right"></i> 流程管理</a></li>
            <li><a href="charts/pie.html"><i class="fa fa-angle-right"></i> 广告管理</a></li>
            <li><a href="charts/bubble.html"><i class="fa fa-angle-right"></i> 消息模板</a></li>
            <li><a href="charts/combinations.html"><i class="fa fa-angle-right"></i> 项目分类</a></li>
            <li><a href="charts/3d.html"><i class="fa fa-angle-right"></i> 项目标签</a></li>
          </ul>
        </li>
        <li class="treeview"> <a href="#"><i class="fa fa-files-o"></i> <span>业务审核</span> <span class="pull-right-container"> <i class="fa fa-angle-left pull-right"></i> </span> </a>
          <ul class="treeview-menu">
            <li><a href="pages/login.html"><i class="fa fa-angle-right"></i> 实名认证审核</a></li>
            <li><a href="register.html"><i class="fa fa-angle-right"></i> 广告审核</a></li>
            <li><a href="forgotPassword.html"><i class="fa fa-angle-right"></i> 众筹审核</a></li>
          </ul>
        </li>
      </ul>
      <!-- sidebar-menu -->
    </section>
  </aside>

  
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper"> 
    <!-- Content Header (Page header) -->
    <section class="content-header" style="margin-bottom: 2%">
      <h1 id="goodName" style="float: left">商品名</h1>
      <div style="margin-left: 20%">
        <input class="form-control" id="keyWord" placeholder="请输入商品名" type="text" style="width: 35%;float: left;padding-top: 0px;padding-bottom: 0px">
        <button type="button" class="btn btn-default" id="searchGoods" >搜索</button>
        <button id="testRedis" type="button" class="btn btn-warning" style="margin-left: 10%">捐款测试接口，请点击...</button>
      </div>
      <ol class="breadcrumb">
        <li><a href="index.html"><i class="fa fa-home"></i> 首页</a></li>
        <li class="active"><i class="fa fa-dashboard"></i> 商品数据</li>
      </ol>
    </section>

      <!-- Main content -->
    <section class="content container-fluid">
      <div class="row">
        <div class="col-lg-3 col-xs-6">
          <div class="media-box plain">
            <div class="media-icon pull-left"><i class="icon-bargraph"></i> </div>
            <div class="media-info">
              <h3>￥<span id="currentAmount">1530</span></h3>
              <span  style="font-size: 130%">已筹金额</span>
            </div>
          </div>
        </div>
        <div class="col-lg-3 col-xs-6">
          <div class="media-box plain">
            <div class="media-icon bg-sea pull-left"><i class="icon-wallet"></i> </div>
            <div class="media-info">
              <h3>￥<span id="targetAmount">8,530</span></h3>
              <span  style="font-size: 130%">目标金额</span>
            </div>
          </div>
        </div>
        <div class="col-lg-3 col-xs-6">
          <div class="media-box plain">
            <div class="media-icon bg-blue pull-left"><i class="icon-basket"></i> </div>
            <div class="media-info">
              <h3 id="fundPeople">935</h3>
              <span  style="font-size: 130%">筹款人数</span>
            </div>
          </div>
        </div>
        <div class="col-lg-3 col-xs-6">
          <div class="media-box plain">
            <div class="media-icon bg-green pull-left"><i class="icon-layers"></i> </div>
            <div class="media-info">
              <h4 id="fundDays">5324</h4>
              <span  style="font-size: 130%">筹款起始日期</span>
            </div>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-lg-12">
          <div class="chart-box">
            <div class="progress-info m-bot-1" style="font-size: 130%">众筹完成度 <span class="pull-right" id="completion">90%</span></div>
            <div class="progress">
              <div  id="completionBar" class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%"><span class="sr-only">40% Complete</span></div>
            </div>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-lg-12">
          <div class="chart-box">
            <h3>筹集走势图</h3>
            <div class="chart">
              <div id="container2"></div> 
            </div>
          </div>
        </div>
      </div>
    </section>
    <!-- content --> 
  </div>
  <!-- content-wrapper --> 
  
  <!-- Main Footer -->
  <footer class="main-footer dark-bg">
    <div class="pull-right hidden-xs"> Version 1.0</div>
    Copyright &copy; 2017 Yourdomian. All rights reserved. </footer>
</div>

<!--隐藏域，放置图标数据用的,id为1-14，14是今天-->

<!--总获筹金额-->
<div id="totalAmount"></div>

<!--当天获筹金额-->
<div id="theDayAmount"></div>

<!-- 获筹金额增幅-->
<div id="amountGrowingRate"></div>

<!-- wrapper -->

<!-- jQuery --> 
<script src="dist/js/jquery.min.js"></script> 
<script src="bootstrap/js/bootstrap.min.js"></script> 
<script src="dist/js/ovio.js"></script> 

<!--charts-->
<script src="plugins/charts/code/modules/exporting.js"></script>
<script type="text/javascript" src="adminCommon.js"></script>
<script src="dist/layer/layer.js"></script>
<script type="text/javascript">
    $(function () {
        //调整搜索输入框高度
        var height = $("#keyWord").next().height();
        $("#keyWord").height(height - 2);

        // 获取该商品基础数据
        var currentAmount = 0;
        var primaryKey = window.location.search.substring(1).split("=")[1];
        $.post("getOneGood", {"primaryKey": primaryKey}, function (resultEntity) {
            if (resultEntity.resultFlag == true) {
                currentAmount = resultEntity.data.currentamount;
                var targetAmount = resultEntity.data.targetamount;
                $("#goodName").text(resultEntity.data.goodname);
                $("#currentAmount").text(currentAmount);
                $("#targetAmount").text(targetAmount);
                if (resultEntity.data.ispass == "1") {
                    $("#completion").text("100%");
                    $("#completionBar").css("width", "100%");
                } else {
                    var completion =Math.floor(Number(currentAmount) / Number(targetAmount)*10000);
                    $("#completion").text(completion/100 + "%");
                    $("#completionBar").css("width", completion/100 + "%");
                }

                // 筹款起始日期
                var createtime = JSON.stringify(resultEntity.data.createtime).split(" ")[0].substring(1);
                $("#fundDays").text(createtime);

                $.post("getGoodChart", {"primaryKey": primaryKey}, function (resultEntity) {
                    if (resultEntity.resultFlag == true) {

                        // 筹款人数
                        var fundPeople = resultEntity.data.fundPeople;
                        $("#fundPeople").text(fundPeople);


                        // 当天获筹金额的数据隐藏域
                        var theDayAmount = "";
                        var date="";
                        var theDayMoney="";
                        var dateArray = new Array();
                        var theDayMoneyArray = new Array();
                        for (var i = 0; i < 14; i++) {
                            // json转字符串
                            var jsonString = JSON.stringify(resultEntity.data.fundMoney[i]);

                            var date0 = jsonString.split(":")[0];
                            date=date0.substring(2,date0.length-1);
                            var theDayMoney0 = jsonString.split(":")[1];
                            theDayMoney = theDayMoney0.substring(0,theDayMoney0.length-1);


                            // 键值对都放进数组，供后续使用；
                            dateArray.push(date);
                            theDayMoneyArray.push(theDayMoney);

                            theDayAmount += "<input type=\"hidden\" id=\"theDayAmount-" + (i + 1) + "\" date=\""+date+"\" value=\"" + theDayMoney + "\">";
                        }
                        $("#theDayAmount").html(theDayAmount);

                        // 总获筹金额的数据隐藏域

                        var sum = theDayMoneyArray[13];
                        var totalAmount = "<input type=\"hidden\" id=\"totalAmount-" + 14 + "\" value=\"" + currentAmount + "\">";
                        for (var i = 13; i > 0; i--) {
                            totalAmount += "<input type=\"hidden\" id=\"totalAmount-" + i + "\" value=\"" + (currentAmount - sum) + "\">";
                            sum= Number(sum) + Number(theDayMoneyArray[i-1]);
                        }
                        $("#totalAmount").html(totalAmount);

                        // 获筹金额增幅
                        var amountGrowingRate = "<input type=\"hidden\" id=\"amountGrowingRate-1\" value=\"" + 0 + "\">";

                        for (var i = 1; i < 14; i++) {
                            var growRate=0;
                            var number2 = Number(theDayMoneyArray[i]);
                            var number1 = Number(theDayMoneyArray[i-1]);
                            if (number2==0 && number1==0){
                                growRate=0;
                                amountGrowingRate += "<input type=\"hidden\" id=\"amountGrowingRate-" + (i + 1) + "\" value=\"" + growRate + "\">";
                            }else if (number2!=0 && number1==0){
                                growRate=100;
                                amountGrowingRate += "<input type=\"hidden\" id=\"amountGrowingRate-" + (i + 1) + "\" value=\"" + growRate + "\">";
                            }else if (number1!=0 && number2==0){
                                growRate=0;
                                amountGrowingRate += "<input type=\"hidden\" id=\"amountGrowingRate-" + (i + 1) + "\" value=\"" + growRate + "\">";
                            }else {
                                growRate = (number2 / number1) * 100 - 100;
                                growRate = Math.floor(growRate * 100) / 100;
                                amountGrowingRate += "<input type=\"hidden\" id=\"amountGrowingRate-" + (i + 1) + "\" value=\"" + growRate + "\">";
                            }
                        }
                        $("#amountGrowingRate").html(amountGrowingRate);

                        setTimeout("delayLoadScript();", 100);
                    } else {
                        layer.msg("趋势图数据获取失败，请刷新...")
                    }
                });

            } else {
                layer.msg("商品信息获取失败，请刷新...");
            }
        });

        $("#testRedis").click(function () {
            window.location.replace("testGoodRedis.html?primaryKey="+primaryKey);
        });

    });

    function delayLoadScript() {
        var script = document.createElement('script');
        script.src = "dist/js/goodChart.js";
        document.body.appendChild(script);

    }
</script>
</body>
</html>